import { axios } from "../utils/request";

const api = {
  TreeDataOffice: "/system/office/getOfficeTreeDataList",
  PageList: "/system/office/list",
  Save: "/system/office/save",
  DELETE: "/system/office/delete",
  OfficeList: "/system/office/checkOfficeList"
};

/**
 * 获取机构树列表
 * parameter: {
 *     name: '',
 *     menuType: 1
 * }
 * @param parameter
 * @returns {*}
 */
export function TreeDataOffice(parameter) {
  return axios({
    url: api.TreeDataOffice,
    method: "get",
    params: parameter
  });
}

/**
 * 获取机构列表
 */
export function PageList(parameter) {
  return axios({
    url: api.PageList,
    method: "get",
    params: parameter
  });
}

/**
 * 新增/修改机构
 * @param {*} data
 */
export function saveSysOffice(data) {
  console.log(data);
  return axios({
    url: api.Save,
    method: "post",
    data: data
  });
}

/**
 * 删除机构
 */
export function deleteSysOffice(id) {
  console.log(id)
  return axios({
    url: api.DELETE,
    method: "DELETE",
    params: id
  });
}

/**
 * 获取授权机构
 */
export function OfficeList(roleId) {
  return axios({
    url: api.OfficeList,
    method: "get",
    params: roleId
  });
}